package com.weipai.demo.service.impl;

import com.weipai.demo.enums.RetCode;
import com.weipai.demo.mapper.DloansManagerMapper;
import com.weipai.demo.mapper.base.loansManagerMapper;
import com.weipai.demo.model.loansManager;
import com.weipai.demo.service.LoansManagerService;
import com.weipai.demo.util.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 赵项阳
 * @Date: 2019/6/22 11:53
 * @Version 1.0
 */
@Service
public class LoansManagerServiceImpl implements LoansManagerService {

    private static final Logger log = LoggerFactory.getLogger(LoansManagerServiceImpl.class);

    @Autowired
    private loansManagerMapper loansManagerMapper;
    @Autowired
    private DloansManagerMapper dloansManagerMapper;

    //信贷经理注册信息
    @Override
    public Response register(loansManager loansManager) {
        Response response=new Response();

        try {
            int i = dloansManagerMapper.selectByName(loansManager.getApplyforName());
            if (i>0){
                response.setCode(RetCode.REPETITION);
                return response;
            }else {
                loansManager.setStatus(0);
                int insert = loansManagerMapper.insert(loansManager);
                response.setCode(RetCode.PUSHSUCCESS);
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("register"+e.getMessage());
        }
        return response;
    }


}
